from django.db import models
from django.core.urlresolvers import reverse
from django.utils.html import mark_safe
from user.models import User

# Create your models here.
class Order(models.Model):

	class Meta:
		db_table = "income"
		verbose_name_plural = '所有订单'
		managed = False

	# def pdf_link(self):
	# 	return mark_safe('<a class="grp-button" href="%s" target="blank">pdf</a>')
    #
	# pdf_link.short_description = 'PDF'

	id = models.PositiveIntegerField(primary_key=True)
	code = models.CharField(max_length=50,null=True,unique=True)
	user_account_id = models.ForeignKey(User,db_column='user_account_id',null=True,related_name='order')
	pay_type_id = models.PositiveIntegerField(blank=True,null=True)
	amount = models.DecimalField(blank=True,null=True,max_digits=12,decimal_places=2)
	voucher = models.CharField(blank=True,null=True,max_length=50)
	bus_state_id = models.PositiveIntegerField(blank=True,null=True)
	gmt_create = models.DateTimeField(blank=True,null=True)
	gmt_modified = models.DateTimeField(blank=True,null=True)
	pay_type = models.CharField(blank=True,null=True,max_length=20)

	def __str__(self):
		return self.code
